|
|
|
|
|
|
|
Listing 21.31. Adding the LoadRights function to the DLL. |
|
|
|
|
|
|
|
|
Private Sub LoadRights()
'
' load user's rights collection
'
Dim strSQL As String
'
strSQL = "SELECT * FROM secAccess WHERE UserID='" & strUserIDProp & "'"
'
Set wsRights = DBEngine.CreateWorkspace("wsUser", "admin", "")
Set dbRights = wsRights.OpenDatabase(strDBName)
Set rsRights = dbRights.OpenRecordset(strSQL, dbOpenSnapshot)
'
blnRightsLoaded = True
'
End Sub |
|
|
|
|
|
|
|
|
Now add the routine to check the access rights for a particular secured object. Create a function called CheckRights and enter the segment of code in Listing 21.32. |
|
|
|
|
|
|
|
|
Listing 21.32. Checking access rights for a secured object with accRights. |
|
|
|
|
|
|
|
|
Public Function CheckRights(strObject As String, urCheck As urLevel) As Boolean
'
' see if user has proper rights
'
On Error GoTo LocalErr
'
If blnRightsLoaded = False Then
LoadRights
End If
'
CheckRights = False ' assume it's not good!
'
With rsRights
.MoveLast
If .RecordCount <> 0 Then
.FindFirst "Object='" & strObject & "'"
If .NoMatch = False Then
CheckRights = (urCheck <= .Fields("[Level]"))
End If
End If
End With
'
Exit Function
'
LocalErr:
Err.Raise Err.Number, App.EXEName & ".usrObject", Err.Description
'
End Function |
|
|
|
|
|